﻿<UserControl x:Class="LiSAClient.WpfClient.View.Frame.Login"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:extensions="clr-namespace:LiSAClient.WpfClient.Resources.Extensions"
             xmlns:pwex="clr-namespace:LiSAClient.WpfClient.Resources.Extensions"
             xmlns:windows1="clr-namespace:LiSAClient.WpfClient.View.Frame.Windows"
             mc:Ignorable="d" 
             d:DesignHeight="700" d:DesignWidth="1000"
             extensions:FrameworkElementExtensions.FocusFirstElement="True">
    <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
        <Border Style="{StaticResource LoginBoxBorderStyle}" Name="BorderLoginBox">
            <Grid Style="{StaticResource LoginBoxGridStyle}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition Height="60"/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>



                <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource LoginBoxTextBlockStyle}" Text="Username" />
                <TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource LoginBoxTextBoxStyle}" Name="TextBoxUsername" Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}" TabIndex="0"/>

                <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource LoginBoxTextBlockStyle}" Text="Password" />
                <PasswordBox Grid.Row="1" Grid.Column="1" Style="{StaticResource LoginBoxPasswordBoxStyle}" Name="PasswordBoxText"
                         pwex:PasswordBoxAssistant.BindPassword="True" 
                         pwex:PasswordBoxAssistant.BoundPassword="{Binding Path=Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         TabIndex="1" >
                    <PasswordBox.InputBindings>
                        <KeyBinding Key="Enter" Command="{Binding Login}" CommandParameter="{Binding ElementName=PasswordBoxText}"/>
                    </PasswordBox.InputBindings>
                </PasswordBox>

                    <CheckBox Grid.Row="2" Grid.Column="1" Content="Save credentials" IsChecked="{Binding IsSaveDataChecked}" Style="{StaticResource LoginBoxCheckBockStyle}"/>

                <Button Grid.Row="3" Grid.Column="1"  Style="{StaticResource HyperlinkLikeButton}" Content="New user?" Command="{Binding NewUser}" Margin="5,0,0,0"  VerticalAlignment="Center"/>
                


                <Button Grid.Row="3" Grid.Column="1" Name="ButtonLogin" Style="{StaticResource LoginBoxButtonStyle}" IsEnabled="{Binding LoginEnabled}"  Command="{Binding Login}" CommandParameter="{Binding ElementName=PasswordBoxText}" TabIndex="3" Content="Login" IsDefault="True"/>
                
                <Label Grid.Row="4" Grid.Column="0" Name="LabelErrorMessage" Grid.ColumnSpan="2" VerticalAlignment="Center"
                   Foreground="Crimson" Width="250" HorizontalAlignment="Left" Content="{Binding Error}"  />

            </Grid>
        </Border>

        <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="20,0">
            <Image Style="{StaticResource LeftMenuLiSADefaultImageStyle}"  />
            <TextBlock Text="{Binding DataContext.Version, RelativeSource={RelativeSource AncestorType=windows1:MainWindow}}" Style="{StaticResource LeftMenuLiSADefaultVersionStyle}" TextOptions.TextRenderingMode="Aliased" Foreground="#C4C5C5"/>
        </StackPanel>
    </Grid>
</UserControl>